from django.db import models
from django.contrib.auth.models import User
from Shikimo.pix.customfields import ImageAndThumbField

class Tag(models.Model):
    tag = models.CharField(max_length = 15)
    
    def __unicode__(self):
        return self.tag
    
class Photo(models.Model):
    author = models.ForeignKey(User)
    title = models.CharField(max_length = 60)
    datetime = models.DateTimeField()
    description = models.TextField(blank = True)
    tags = models.ManyToManyField(Tag, blank = True, null = True)
    related = models.ManyToManyField('self', blank = True, null = True)
    image = ImageAndThumbField(upload_to = 'upload')

    def __unicode__(self):
        
        return self.author.username + " - " + self.title + " id:" + str(self.id)
    
class UserProfile(models.Model):
    user = models.ForeignKey(User, unique = True)
    nickname = models.CharField(max_length = 15, blank = True)
    summary = models.TextField(blank = True)
